<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<html>
	<head>
		<title>选择用户</title>
		<script src="${contextPath}/scripts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
		<script src="${contextPath}/scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
		<link href="${contextPath}/styles/default.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
		function jumpPage(page) {
			buildAll();
			var searchForm = document.searchForm;
			searchForm.action = "<s:property value='contextPath'/>/system/user/chooseUser.do?currentPage=" + page;
			searchForm.submit();
		}
		
		function buildAll(){
			var check = $("input[name='mid']:checked"); //得到所有被选中的checkbox
			   var ids=$("#allIds").val();              //定义变量
			   check.each(function(i){         //循环拼装被选中项的值
				   if(i!=check.length-1){
					   ids+=$(this).attr('id')+',';
				   }else{
					   ids+=$(this).attr('id');
				   }
			    });
			   $("#allIds").val(ids);
		}
		
		function choose(){
			buildAll();
			var d='';
			var ids_=$("#allIds").val();
			if(ids_!=null&&ids_!=''){
				$.ajax({
					  async:false,
					  type: 'POST',
					  url: "<s:property value='contextPath'/>/system/user/getUserNames.do?allIds="+$("#allIds").val(),
					  dataType: "json",
					  success: function(data) {
							  	d = data.data;
							}		
						,
						error:function(data){
						}
					});
			}
			window.opener.choose_user(ids_,d);
			window.close();
		}
		
		$(document).ready(function(){            
			$("#check_all").click(function(){  
				$('[type=checkbox]').attr('checked', $("#check_all").is(':checked'));
			});
			
			var d=$("#pageIds").val();
			if(d!=null&&d.length>0){
				var ary=d.split(",");
				if(ary!=null&&ary.length>0){
					for(var i=0;i<ary.length;i++){
						if(ary[i]!=''&&$("#"+ary[i]).length>0){
							$("#"+ary[i]).attr("checked",true);
						}
					}
				}
			}
		});
		function clear1(){
			document.getElementById("realName").value="";
		}
		</script>
	</head>
	<body>
      <form name="searchForm" id="searchForm" method="post" action="chooseUser.do">
	      <table width="100%" border="0" cellspacing="-1" cellpadding="-1">
	        <tr>
	        	<td class="right-td-width-bg">姓名：</td>
	        	<td>
	        		<input type="text" id="realName" name="us.realName" value="${us.realName }" class="input" size="20"/>
	        	</td>
	        	<td width="50%">  </td>
	        </tr>
	        <tr style="background:url(${contextPath}/images/xt_main_right_dhbj.jpg) repeat-x;">
					<td colspan="3" align="right">
				    	<input type="button" class="btn_clear_form" value="" onclick="clear1()"/>
				    	<input type="submit" value="" class="btn_query"/>
			    	</td>
			</tr>
	      </table>
      
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
		  <tr>
		    <td height="25" align="left"><font color="#0066CC"><strong>用户列表：</strong></font></td>
		    <td height="25" align="right">
            </td>
		  </tr>
		</table>
	<input type="hidden" name="post" value="<s:property value="post"/>" />
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
	  <tr> 
	    <td width="3%" class="top-td-width-bg"><input type="checkbox" id="check_all" name="check_all" /></td>
	    <td width="5%" class="top-td-width-bg">序号</td>
		<td width="30%" class="top-td-width-bg">姓名</td>
		<td width="30%" class="top-td-width-bg">性别</td>
		<td width="32%" class="top-td-width-bg">职位</td>
	  </tr>
	 <s:iterator value="page.result" status="st" >
		<tr> 
			<td class="down-center-td-width-bg">
				<input name="mid" type="checkbox"  id="<s:property value="id"/>" class="np" />
			</td>
			<td class="down-left-td-width-bg"><s:property value="#st.index+1"/></td>
		    <td class="down-left-td-width-bg"><s:property value="realName"/></td>
			<td class="down-left-td-width-bg"><s:property value="sex"/></td>
			<td class="down-left-td-width-bg"><s:property value="post.name"/></td>
		</tr>
	</s:iterator>
	<tr bgcolor="#F9FCEF"> 
	 <td height="36" colspan="12" align="center">
			<%@ include file="/WEB-INF/view/common/pagination.jsp"%>
	 </td>
	</tr>
	<tr>
		<td colspan="5">
			<input type="hidden" id="pageIds" name="pageIds" value="<s:property value='pageIds'/>" />
			<input type="hidden" id="allIds" name="allIds" value="<s:property value='allIds'/>" />
			<input type="button" onclick="choose()" class="btn_qd" value="  "/><input type="button" value="  " class="btn_return" onclick="window.close()"/>
		</td>
	</tr>
	</table>
	</form>
	</body>
</html>